<template>
  <div>
    <!-- 表格 -->
    <list-vue @willupdate="willupdate" :arr="arr" @init="getlist"></list-vue>
    <!-- 弹框 -->
    <!-- 3.将info传给form -->
    <!-- 6.4将arr传给form -->
    <!-- 6.5绑定自定义事件 init -->
    <form-vue :info="info" :arr="arr" @init="getlist" ref="form"></form-vue>
  </div>
</template>
<script>
import listVue from "./components/list.vue";
import formVue from "./components/form.vue";
import { mapGetters, mapActions } from "vuex";
import { reqmemberlist } from "../../http/api";
export default {
  components: {
    listVue,
    formVue,
  },
  props: [],
  data() {
    return {
      // 1.初始化弹框出现的状态
      info: {
        isshow: false,
        isAdd: true,
      },
      // 6.1初始化列表数据
      arr: [],
    };
  },
  computed: {
    ...mapGetters({}),
  },
  mounted() {
    this.getlist();
  },
  methods: {
    ...mapActions({}),
 
    // 7.点了编辑
    willupdate(uid) {
      this.info.isshow = true;
      this.info.isAdd = false;
      // 让form调用发请求
      this.$refs.form.getOne(uid)
    },
    // 6.2请求列表
    getlist() {
      reqmemberlist({istree:true}).then((res) => {
        if (res.data.code == 200) {
          this.arr = res.data.list ? res.data.list : [];
        }
      });
    },
  },
};
</script>
<style scoped lang="less">
@import "../../less/index.less";
</style>